<?php

namespace Someline\Api\Controllers;

use Illuminate\Http\Request;
use Someline\Component\Wechat\Api\Controllers\SomelineWechatsControllerBase;
use Someline\Component\Wechat\SomelineWechatService;
use Someline\Presenters\BasicPresenter;

class SomelineWechatsController extends SomelineWechatsControllerBase
{

    public function getMaterialMedia($mediaId)
    {
        $app = SomelineWechatService::getWechatApplication();
        $material = $app->material;

        $result = $material->get($mediaId);
        //$result = $result->toArray();

        return (new BasicPresenter())->present($result);
    }

    public function postMaterialArticle(Request $request, $mediaId)
    {
        $app = SomelineWechatService::getWechatApplication();
        $material = $app->material;

        $result = $material->updateArticle($mediaId, $request->all());


        $result = $result->toArray();

        return (new BasicPresenter())->present($result);
    }

}
